#include "recordingwidget.h"
#include <KWindowSystem>
//#include "ukuiwindowhelper/ukuiwindowhelper.h"
#include "windowmanager/windowmanager.h"
RecordingWidget::RecordingWidget(QWidget *parent) : QWidget(parent)
{
    if (!(m_info.waylandDectected() && !m_info.isHWWayland() && (m_info.windowManager() == DesktopInfo::UKUI)))
    {
        setWindowFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus |Qt::WindowStaysOnTopHint);//
        setAttribute(Qt::WA_TranslucentBackground); //透明
        setAttribute(Qt::WA_TransparentForMouseEvents, true); //鼠标穿透
        setWindowFlags( Qt::X11BypassWindowManagerHint);
    }
    else
    {
        setWindowFlags(Qt::FramelessWindowHint | Qt::WindowTransparentForInput);//
        setAttribute(Qt::WA_TranslucentBackground); //透明

//        UkuiWindowHelper *windowHelper = new UkuiWindowHelper(this);
//        windowHelper->setSkipTaskBar(true);
//        windowHelper->setSkipSwitcher(true);
//        UkuiWindowHelper::States states;
//        states |= UkuiWindowHelper::State::KeepAbove;
//        windowHelper->setWindowState(states);
        KWindowSystem::setType(winId(), NET::OnScreenDisplay);
        kdk::WindowManager::setSkipTaskBar(this->windowHandle(), true);
        kdk::WindowManager::setSkipSwitcher(this->windowHandle(), true);
    }
}

void RecordingWidget::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(QPen(QColor("#3790FA"), 2, Qt::DashLine));   // 设置蓝色虚线
    painter.drawRect(this->rect().adjusted(1, 1, -1, -1));      //小一圈
}

void RecordingWidget::keyPressEvent(QKeyEvent *e)
{
    QWidget::keyPressEvent(e);
}
